1. Field of the Invention
This invention relates generally to the field of computer graphics and, more particularly, to high performance graphics systems.
2. Description of the Related Art
A computer system typically relies upon its graphics system for producing visual output on the computer screen or display device. Early graphics systems were only responsible for taking what the processor produced as output and displaying it on the screen. In essence, they acted as simple translators or interfaces. Modern graphics systems, however, incorporate graphics processors with a great deal of processing power. They now act more like coprocessors rather than simple translators. This change is due to the recent increase in both the complexity and the amount of data being sent to the display device. For example, modern computer displays have many more pixels, greater color depth, and are able to display images that are more complex with higher refresh rates than earlier models. Similarly, the images displayed are now more complex and may involve advanced techniques such as anti-aliasing and texture mapping.
As a result, without considerable processing power in the graphics system, the CPU would spend a great deal of time performing graphics calculations. This could rob the computer system of the processing power needed for performing other tasks associated with program execution and thereby dramatically reduce overall system performance. With a powerful graphics system, however, when the CPU is required to draw a box on the screen, the CPU is freed from having to compute the position and color of each pixel. Instead, the CPU may send a request to the graphics system stating, xe2x80x9cdraw a box at these coordinatesxe2x80x9d. The graphics system then draws the box, thereby freeing the CPU to perform other tasks.
Generally, a graphics system in a computer system is a type of video adapter that contains its own processor to boost performance levels. These processors are specialized for computing graphical transformations, so they tend to achieve better results than the general-purpose CPU used by the computer system. In addition, they free up the computer""s CPU to execute other commands while the graphics system is handling graphics computations. The popularity of graphical applications, and especially multimedia applications, has made high performance graphics systems a common feature of computer systems. Most computer manufacturers now bundle a high performance graphics system with their systems.
Since graphics systems typically perform only a limited set of functions, they may be customized and therefore be far more efficient at graphics operations than the computer""s general-purpose central processor. While early graphics systems were limited to performing two-dimensional (2D) graphics, their functionality has increased to support three-dimensional (3D) wire-frame graphics, 3D solids, and now includes support for 3D graphics with textures and special effects such as advanced shading, fogging, alpha-blending, and specular highlighting.
The processing power of 3D graphics systems has been improving at a breakneck pace. A few years ago, shaded images of simple objects could only be rendered at a few frames per second, while today""s systems support rendering of complex 3D objects at 60 frames per second or higher.
In order to render a 3D object, the 3D object must be organized or projected, in the mathematical sense, from 3D space onto a 2D display device. The display device can be the retina of the human eye, the film of a photographic camera, a projector screen, a head-mounted display, or a computer display screen. Typically, computer graphics systems use a xe2x80x9cperspective projectionxe2x80x9d that mimics the way a human eye and the way a photographic camera project 3D images onto a 2D plane. Computer graphics systems project the 3D world onto a viewport, an imaginary 2D surface between the 3D world and the viewpoint. The viewpoint represents the assumed position of a viewer. The projected image may then be transformed for viewing on a computer display screen.
FIGS. 1A and 1B are used to provide definitions for the coordinate system that is typically used to represent the distance of an object from the viewpoint for a particular viewport. FIG. 1A is a top view from above viewport 100, and FIG. 1B is a view from behind viewpoint 102 and viewport 100. As shown in FIGS. 1A and 1B, distance x is the horizontal distance from object 103 to viewpoint 102, distance y is the vertical distance from object 103 to viewpoint 102, and distance z is the depth distance from object 103 to viewpoint 102. Furthermore, note that the horizontal distance x is measured along a direction parallel to the top and bottom edges of viewport 100, the vertical distance y is measured along a direction parallel to the left and right edges of viewport 100, and the depth distance z is measured along a direction perpendicular to the surface of viewport 100.
While the number of pixels is an important factor in determining graphics system performance, another factor of equal import is the quality of the image. One visual effect used by graphics systems to increase the realism of computer images is called xe2x80x9cfoggingxe2x80x9d. Fogging is a technique by which the color of objects can be reduced in intensity or blended with other colors so that the objects appear to be buried in fog, mist, or smoke. To give the impression of an object obscured by fog, the graphics system typically blends constant fogging color values with the color values of the object. The resulting fog-shaded color typically retains some of the object""s original color. The weight of the constant fogging color in the blending, which also represents the amount of fogging applied, is typically a function of the distance of the object from the viewpoint. The further away that an object is from the assumed location of the viewer, the more fog-shaded the object appears. Beyond a certain distance, the object may appear to be totally occluded by the fog, mist, or smoke. In these cases, the object may simply be assigned the color of the fog. Note that, as used herein, the word fog is used to also refer to mist, smoke, or any other phenomenon that has the effect of reducing visibility.
In prior art graphics systems, the amount of fogging depends on the depth distance z from the object to the viewpoint. Since the depth distance z does not represent the actual distance from the viewpoint to the object, certain limitations exist for prior art graphics systems that use the depth distance z for implementing fogging. These limitations and other artifacts associated with using the depth distance z to implement fogging are described below with the aid of FIGS. 2A and 2B.
FIG. 2A shows 2D viewport 100 with 3D space 116 located behind viewport 100. Objects that are located in 3D space 116, such as objects 108 and 110, are projected onto viewport 100 to form images that may be later transformed so that they may be displayable on a computer display screen. For the projection, the graphics system assumes that a viewer is located at viewpoint 102. For this discussion, a typical fogging model is assumed for the prior art graphics system where fogging is applied according to fogging plane 104 that is located a certain depth distance zF from viewpoint 102. A full amount of fogging is applied to objects that have depth distance z greater than zF, and no fogging is applied to objects that have depth distance z less than zF. Applying no fogging is implemented by displaying the color values of objects unchanged. Applying a full amount of fogging is implemented by discarding the color values of an object and replacing the object""s color values with the constant fogging color values. As shown in FIG. 2A, object 108 has a z value that is less than zF and as a result is displayed without any fogging applied, and object 110 has a z value that is greater than zF and as a result is displayed with a full amount of fogging applied.
FIG. 2B shows a view obtained by a rotation of viewport 100 about the y-axis that passes through viewpoint 102. Such a rotation may take place, for example, when the assumed viewer at viewpoint 102 changes viewing direction. Note that the positions of all objects in 3D space 116, including objects 108 and 110, have remained unchanged. Furthermore, note that the distance from viewpoint 102 to fogging plane 104, objects 108, and object 110 has not changed. As a result of the rotation, a full amount of fogging is now applied to object 108 since it is now located behind fogging plane 104, and no fogging is applied to object 110 since it is now located in front of fogging plane 104. Since the actual distance from viewpoint 102 to the objects has remained the same, the amount of fogging applied to the objects should have also remained the same. Assuming that the fog that obscures the objects is isotropic, visibility should equally decrease in all directions. Rotations that have no effect on the distance from the objects to viewpoint 102 should have no effect on the amount of fogging that is applied to these objects.
Thus, an improved system and method would desirable that better implement fogging in computer graphics so that the artifacts and limitations described above may be reduced or eliminated.
To obtain images that are more realistic, some prior art graphics systems have gone further by generating more than one sample per pixel. As used herein, the term xe2x80x9csamplexe2x80x9d refers to calculated color information that indicates the color, depth (z), transparency, and potentially other information, of a particular point on an object or image. For example, a sample may comprise the following component values: a red value, a green value, a blue value, a z value, and an alpha value (representing the transparency of the sample). A sample may also comprise other information, e.g., a z-depth value, a blur value, an intensity value, brighter-than-bright information, and an indicator that the sample consists partially or completely of control information rather than color information (i.e., xe2x80x9csample control informationxe2x80x9d). By calculating more samples than pixels (i.e., super-sampling), a more detailed image is calculated than can be displayed on the display device. For example, a graphics system may calculate four samples for each pixel to be output to the display device. After the samples are calculated, they are combined or filtered to form the pixels that are stored in the frame buffer and then conveyed to the display device. Using pixels formed in this manner may create a more realistic final image because overly abrupt changes in the image may be smoothed by the filtering process.
These prior art super-sampling systems typically generate a number of samples that are far greater than the number of pixel locations on the display. These prior art systems typically have rendering processors that calculate the samples and store them into a render buffer. Filtering hardware then reads the samples from the render buffer, filters the samples to create pixels, and then stores the pixels in a traditional frame buffer. The traditional frame buffer is typically double-buffered, with one side being used for refreshing the display device while the other side is updated by the filtering hardware. Once the samples have been filtered, the resulting pixels are stored in a traditional frame buffer that is used to refresh to display device.
A system capable of performing more realistic fogging (e.g., in real-time or near real-time) while retaining the advantages of super-sampling is desired.
An improved computer graphics system configured to render 3D objects that are obscured by fog, mist, or smoke more realistically by applying a variable amount of fogging to the objects, wherein the variable amount of fog depends on the radial distance from the object to the viewpoint.
In one embodiment, the graphics system applies a variable amount of fogging that depends on the cylindrical radial distance from the object to the viewpoint. The cylindrical radial distance, defined as {square root over (x2+z2)}, depends on the horizontal distance x and the depth distance z from the object to the viewpoint and is independent of the vertical distance y. The cylindrical distance represents a significant improvement over the depth distance z used by prior art methods. The cylindrical radial distance remains unchanged during rotations of the viewport and/or the viewing direction of an assumed viewer about a vertical axis that passes through the viewpoint. Thus, the amount of fogging applied to objects remains unchanged through these rotations since the amount of fogging applied is dependent on the cylindrical radial distance that remains unchanged.
In another embodiment, the graphics system applies a variable amount fogging to graphics objects according to a spherical radial distance between an object and the viewpoint. The spherical distance is calculated using the formula: {square root over (x2+y2+z2)}, where x is the horizontal distance from the object to the viewpoint, where y is the vertical distance from the object to the viewpoint, and where z is the depth distance from the object to the viewpoint. The spherical distance remains the same through rotations of the viewport and/or viewing direction of an assumed viewer about any axes that pass through the viewpoint. Thus, the amount of fogging applied to objects remains unchanged through these rotations since the amount of fogging applied is dependent on the spherical radial distance that remains unchanged.
In one embodiment, the 3D space may be divided into several different regions by several concentric cylinders or spheres that are each at a constant cylindrical or spherical distance from the viewpoint. Fogging for each region is then applied according to different mathematical functions. The different mathematical functions may dictate no fogging to be applied, a full amount of fogging to be applied, or a variable amount of fogging to be applied. The variable amount may vary as a function of cylindrical or spherical distance.